package com.szsfm.vehiclemanagement.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by zhoubigbo on 2017/10/13.
 */
public class NetworkUtil {

    /**
     * 判断手机是否有网络
     * @param context
     * @return
     */
    public static boolean hasNetwork(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getActiveNetworkInfo();
        return (null != ni && ni.isAvailable());
    }

}
